<!--
 * @Description: 鼠标事件
 * @Author: rendc
 * @Date: 2021-09-07 11:19:33
 * @LastEditors: rendc
 * @LastEditTime: 2021-09-07 11:34:47
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>鼠标事件</title>
  <style>
    #app {
      width: 100px;
      height: 100px;
      border: 1px solid hotpink;
    }
  </style>
</head>

<body>
  <div id="app">

  </div>
</body>
<script>
  var div = document.getElementById("app");
  // console.log(div);
  var handler = function (event) {
    console.log(event.type);
    // switch (event.type) {
    //   case "click":
    //     console.log("鼠标点击");
    //     break;
    //   case "mouseover":
    //     console.log("光标移入");
    //     break;
    // }
  }
  div.onclick = handler;
  div.onmouseover = handler;
  div.onmousedowm = handler;
  div.onmouseout = handler;
  // div.onmousemove = handler;
  // 坐标点
  div.onclick = function (event) {
    console.log("页面坐标位置：" + event.pageX + ',' + event.pageY);
    console.log("屏幕坐标位置：" + event.screenX + ',' + event.screenY);
    console.log("客户区坐标位置：" + event.clientX + ',' + event.clientY);
  }
</script>

</html>